package com.boornet.encrypt.util;

import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

/**
 * Created by zcx on 2021/2/23.
 */
public class BCrypt {

    /**
     * 随机加盐 与 匹配
     * @param args
     */
    public static void main(String[] args) {
        String password = "123456";
        BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
        String hashedPassword = passwordEncoder.encode(password);
        System.out.println(hashedPassword);
        // $2a$10$bdzvPmgKe9fhmdtEiUqC7e5P06DKjJM.1kFxi4Bzzw0pVJtfAI4zW
        // $2a$10$HeGAVv1uaSsrAuKSmRybdeZEr.iMMLJF.mE1JqLorHacBAhk85gvy

        boolean f = passwordEncoder.matches(password, hashedPassword);
        System.out.println(f);
    }
}
